const handleGenderChange = (e) => {
  console.log('性别选择:', e);
};
const schema = {
  type: "object",
  properties: {
    input: {
      type: "string",
      title: "账号",
      required: true,
      "x-decorator": "FormItem",
      "x-component": "Input",
      "x-component-props": {
        placeholder: "请输入",
        allowClear: true,
        // 定义事件
        onChange: (e) => {
          handleGenderChange(e)
        },
      },
    },
    input2: {
      title: "密码",
      type: "string",
      required: true,
      "x-decorator": "FormItem",
      "x-component": "Input",
      "x-component-props": {
        placeholder: "请输入",
        style: {
          marginBottom: "16px",
        },
      },
      "x-reactions": [
        {
          dependencies: ["input"],
          fulfill: {
            state: {
              visible: "{{$deps[0] ? true : false}}",
            },
          },
        },
      ],
    },
    age: {
      title: "年龄",
      type: "number",
      required: true,
      "x-decorator": "FormItem",
      "x-component": "InputNumber",
      "x-component-props": {
        placeholder: "请输入年龄",
        style: {
          marginBottom: "16px",
        },
      },
      "x-reactions": [
        {
          dependencies: ["input"],
          fulfill: {
            state: {
              visible: "{{$deps[0] ? true : false}}",
            },
          },
        },
      ],
    },
    gender: {
      type: "string",
      title: "性别",
      required: true,
      "x-decorator": "FormItem",
      "x-component": "Select",
      "x-component-props": {
        placeholder: "请选择性别",
        style: {
          marginBottom: "16px",
        },
        // 添加 onChange 事件处理函数
        onChange: (e) => {
          handleGenderChange(e);
        },
      },
      enum: [
        { label: "Male", value: "male" },
        { label: "Female", value: "female" },
      ],
      "x-reactions": [
        {
          dependencies: ["input"],
          fulfill: {
            state: {
              visible: "{{$deps[0] ? true : false}}",
            },
          },
        },
      ],
    },
    switchGroup: {
      type: "void",
      "x-component": "FormGrid",
      "x-component-props": {
        maxColumns: 3,
        minColumns: 1,
        onChange: (e) => {
          handleGenderChange(e);
        },
      },
      properties: {
        switch: {
          type: "boolean",
          title: "是否开启",
          required: true,
          "x-decorator": "FormItem",
          "x-component": "Switch",
          "x-decorator-props": {
            // layout: 'vertical',
            // 上下对其
            // style: styleObj,

          },
          "x-reactions": [
            {
              dependencies: ["input"],
              fulfill: {
                state: {
                  visible: "{{$deps[0] ? true : false}}",
                },
              },
            },
          ],
        },
        switch1: {
          type: "boolean",
          title: "是否开启111",
          required: true,
          "x-decorator": "FormItem",
          "x-component": "Switch",
          "x-decorator-props": {
            // layout: 'vertical',
            // style: styleObj,
          },
          "x-component-props": {
            onChange: (e) => {
              handleGenderChange(e);
            },
          },
          "x-reactions": [
            {
              dependencies: ["input"],
              fulfill: {
                state: {
                  visible: "{{$deps[0] ? true : false}}",
                },
              },
            },
          ],
        },
        switch2: {
          type: "boolean",
          title: "是否开启",
          required: true,
          "x-decorator": "FormItem",
          "x-component": "Switch",
          "x-decorator-props": {
            // layout: 'vertical',
            // style: styleObj,
          },
          "x-reactions": [
            {
              dependencies: ["input"],
              fulfill: {
                state: {
                  visible: "{{$deps[0] ? true : false}}",
                },
              },
            },
          ],
        },
        // customForm: {
        //   type: "string",
        //   title: "自定义表单",
        //   // 获取组件里面的值
        //   "x-decorator": "FormItem",
        //   "x-component": "Demo",
        // },
      },
    },
  },
};

export default schema;
